import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-07-01
 * Time: 21:26
 */
public class test2 {
    public boolean isPalindrome(ListNode head) {
        List<ListNode> list = new ArrayList<ListNode>();
        ListNode cur = head;
        while(cur!=null){
            list.add(cur);
            cur = cur.next;
        }
        int left = 0;
        int right = list.size()-1;
        while(left<right){
            if(list.get(left).val != list.get(right).val){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }

    class ListNode{
        ListNode next;
        int val;

        public ListNode(ListNode next,int val){
            this.next = next;
            this.val = val;
        }
    }
}
